package com.my.hotel.controller;

import com.my.hotel.entity.EvaReply;
import com.my.hotel.service.EvaReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.text.SimpleDateFormat;
import java.util.Date;

@Controller
@RequestMapping("/evaReply")
public class EvaReplyController {

    @Autowired
    private EvaReplyService evaReplyService;

    @RequestMapping("/toEvaReplyJsp")
    public String toEvaReplyJsp(Integer id, Model model){
        model.addAttribute("evaId",id);
        return "evaReplyAdd";
    }

    @RequestMapping("/evaReplyAdd")
    public String evaReplyAdd(EvaReply evaReply, Model model){
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = sdf.format(date);
        evaReply.setReplyTime(format);
        evaReplyService.addEvaReply(evaReply);
        return "redirect:/eva/getEvaDTOList";
    }
}
